<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html>
<html>
<head>
<base href="${BaseContext }">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加更新订单</title>
<link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.js"></script>
</head>
<body>

<nav class="navbar-inverse">
	<div class="container">
		<!-- Brand and toggle get grouped for better mobile display -->
		<div class="navbar-header">
			<a class="navbar-brand" href="#">宾馆客房管理系统 : </a>
		</div>
		<div class="collapse navbar-collapse"
			 id="bs-example-navbar-collapse-9">
			<ul class="nav navbar-nav">
				<li  ><a href="${pageContext.request.contextPath}/room/list.do">客房管理</a></li>
				<li class="active"><a href="${pageContext.request.contextPath}/order/list.do">订单管理</a></li>
				<li ><a href="${pageContext.request.contextPath}/customer/list.do">客户管理</a></li>
				<li ><a href="${pageContext.request.contextPath}/user/list.do">员工管理</a></li>
				<li ><a href="${pageContext.request.contextPath}/behind/Mouth.jsp">月营业额统计</a></li>
				<li ><a href="${pageContext.request.contextPath}/behind/Year.jsp">年营业额统计</a></li>
			</ul>
			<p class="navbar-text navbar-right">
				<span>${username}</span> <i class="glyphicon glyphicon-log-in" aria-hidden="true"></i>&nbsp;&nbsp;
				<a href="${pageContext.request.contextPath}/exit.do" class="navbar-link">退出</a>
			</p>
		</div>
	</div>
</nav>

<div class="jumbotron" style="padding-top: 55px;padding-bottom: 15px;">
		<div class="container">
			<c:if test="${empty order.id}">
				<h2>添加订单</h2>
			</c:if>
			<c:if test="${not empty order.id}">
				<h2>更新订单信息</h2>
			</c:if>
		</div>
	</div>


	<div class="container" style="margin-top: 20px;">

		<form id="form" class="form-horizontal" action="${pageContext.request.contextPath}/order/addOrder.do?strId=${order.id}&updateCustomerId=${order.orderCustomerId}"
			method="post" enctype="multipart/form-data">
			<input value="${order.id}" name="strId"  type="hidden" >
			<input value="${order.orderCustomerId}" name="CustomerId"  type="hidden" >
			<div class="form-group">
				<label  class="col-sm-2 control-label">姓名</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="name"
						   placeholder="姓名" value="${customer.name}">
				</div>
			</div>

			<div class="form-group">
				<label  class="col-sm-2 control-label">身份证</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="idcard"
						   placeholder="身份证" value="${customer.idcard}">
				</div>
			</div>

			<div class="form-group">
				<label  class="col-sm-2 control-label">年龄</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="age"
						   placeholder="年龄" value="${customer.age}">

				</div>
			</div>
			<div class="form-group">
				<label  class="col-sm-2 control-label">性别</label>
				<div class="col-sm-10">
					男<input type="radio" name="sex" value="男" ${customer.sex=="男"?"checked":""}>&nbsp;
					女<input type="radio" name="sex" value="女" ${customer.sex=="女"?"checked":""}>
				</div>
			</div>
			<div class="form-group">
				<label  class="col-sm-2 control-label">手机号</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="tel"
						   placeholder="手机号" value="${customer.tel}">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-2 control-label">入住时间 :
				</label>
				<label class="col-sm-2 control-label">${customer.starttime}
				</label>
				<div class="col-sm-8">
					<input type="date" class="form-control" name="starttime"
						   placeholder="客户入住时间"  value="${customer.starttime}"/>

				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">退房时间 : </label>
				<label class="col-sm-2 control-label">${customer.endtime}</label>
				<div class="col-sm-8">
					<input type="date" class="form-control" name="endtime"
						   placeholder="离开时间"  value="${customer.endtime}"/>
				</div>
			</div>


			<div class="form-group">
				<label  class="col-sm-2 control-label">房间类型</label>
				<div class="col-sm-10">

					<select id="roomType" name="type" class="form-control">
						<option class="form-control" value="" >下拉选择客房类型</option>
						<option class="form-control" value="刺激心跳房" ${customer.type == "刺激心跳房" ? 'selected':''}>刺激心跳房</option>
						<option class="form-control" value="浪漫双人房" ${customer.type == "浪漫双人房" ? 'selected':''}>浪漫双人房</option>
						<option class="form-control" value="无敌快乐房" ${customer.type == "无敌快乐房" ? 'selected':''}>无敌快乐房</option>
						<option class="form-control" value="豪华海景房" ${customer.type == "豪华海景房" ? 'selected':''}>豪华海景房</option>
					</select>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-2 control-label">房间号</label>
				<div class="col-sm-10">
					<select id="roomNum"  name="roomid" class="form-control">
						<option value="${customer.roomid}" >${order.roomnum}</option>
					<option id="roomOption" value="">下拉选择房间号</option>
					</select>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-2 control-label">押金</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="orderCash"
						placeholder="押金"  value="${order.orderCash}"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">是否退还押金</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="orderCashback"
						placeholder="是否退还押金"  value="${order.orderCashback}"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">住宿时长</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="orderTime"
						placeholder="住宿时长"  value="${order.orderTime}"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">费用</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="orderMoney"
						placeholder="费用"  value="${order.orderMoney}"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">备注</label>
				<div class="col-sm-10">
					<textarea name="notes" style="width: 950px;height: 100px">
						${customer.notes}
					</textarea>

				</div>
			</div>

			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="submit" class="btn  btn-primary">保存</button>
					<a href="/order/list.do" class="btn btn-default">返回列表</a>
				</div>
			</div>

		</form>

	</div>
<script type="text/javascript">
	$("#roomType").change(function() {
		//alert("客房类型"+$("#roomType").val());
		$.ajax({
			url: "${pageContext.request.contextPath}/order/ajaxFindRoomNum.do",
			type: "post",
			data: {"roomType":$("#roomType").val()},
			dataType:"json",
			success: function (data) {
				console.log(data);
				//alert("房间号 : "+data.data[0].roomnum);
				$("#roomNum").empty();
				$.each(data.data, function(i,item){
					//alert("item.id:"+item.id);
					$("#roomNum").append("<option class=\"form-control\" value="+item.id+">"+item.roomnum+"</option>");
				});
			},
			error: function () {
				alert("服务器正忙,请稍后再试!")
			}
		});
	})
</script>


</body>
</html>